|
|
|
|
|
|
|
· Inform the user of range limits. If a field has a high or low range limit, tell the user what the limits are. |
|
|
|
|
|
|
|
|
· Point out required fields on a form. Mark required fields with a leading asterisk (*) or some other appropriate character. Possibly change the background color of required fields. |
|
|
|
|
|
|
|
|
· Group conditional fields together on the form. If entering Yes in one field means that several other fields must be completed, put the additional fields close to the Yes/No field to help the user. Keep conditional fields of this type disabled until the Yes/No flag has been set. This helps the user see that new fields must be entered. |
|
|
|
|
|
|
|
|
The first level of validation is at the field level. This is the place where you can make sure the user is entering the right characters in the field, entering the data into the field in the proper format, and entering a valid value based on a list of possible choices. |
|
|
|
|
|
|
|
|
For the rest of this section, you will be building a sample application that illustrates the various input validation methods this chapter covers. If you haven't done so already, start up Visual Basic 5 and create a new Standard EXE project. Set the caption of the form to Input Validation and the Name of the form to frmValidation. Set the project Name property to Validation and save the form as VALIDATION.FRM; save the project as VALIDATION.VBP. |
|
|
|
|
|
|
|
|
One of the easiest ways to perform input validation is to filter keyboard input. Filtering keyboard input requires capturing the keystrokes of the user before they appear on the screen and filtering out the keystrokes you do not want to appear in the input controls. You can filter invalid or undesirable keystrokes by creating a beep for the user each time an invalid key is pressed (for example, a beep each time a letter is pressed in a numeric field). You can also convert the invalid key to a valid one (for example, change lower case to upper case). Or you can simply ignore the keystroke completely and prevent the invalid values from ever appearing in the input control. |
|
|
|
|
| |
|
|
|
|
Keep in mind that not all your potential users may be able to hear an audible beep and could become confused at the inability to input data. Windows 95 has several useful Accessibility Options that you may want to review, including the use of message boxes for hearing-impaired users. |
|
|
|
|
|
|
|